import { d_books_dk } from 'xlsx/books_dk';
import { d_books_dly } from 'xlsx/books_dly';
import { d_books_dz } from 'xlsx/books_dz';
import { d_books_fs } from 'xlsx/books_fs';
import { d_books_ms } from 'xlsx/books_ms';
import { d_books_qs } from 'xlsx/books_qs';
import { d_books_sm } from 'xlsx/books_sm';
import { d_books_ss } from 'xlsx/books_ss';
import { d_books_ws } from 'xlsx/books_ws';
import { d_books_yx } from 'xlsx/books_yx';
import { d_books_zs } from 'xlsx/books_zs';
import { d_cus_items } from 'xlsx/cus_items';
import { d_shop_items } from 'xlsx/shop_items';

export default class ItemDB {
    // 全部技能书
    allSkillBooks: SkillBookModel[] = [];
    allSkillBooksMap: { [key: string]: SkillBookModel } = {};
    allSkillIds: string[] = [];
    // 免费技能书
    normalSkillBooks: SkillBookModel[] = [];

    // 所有装备数据
    allEquips: ShopItemModel[] = [];
    allEquipsMap: { [key: string]: ShopItemModel } = {};

    constructor() {
        this.initSkillBooksData();
        this.initEquipsData();
    }
    initEquipsData() {
        this.allEquips = [...d_shop_items, ...d_cus_items];
        for (let i = 0; i < this.allEquips.length; i++) {
            this.allEquipsMap[this.allEquips[i].id] = this.allEquips[i];
        }
    }
    initSkillBooksData() {
        this.normalSkillBooks = [...d_books_dk, ...d_books_dz, ...d_books_fs, ...d_books_ms, ...d_books_qs, ...d_books_sm, ...d_books_ss, ...d_books_zs];
        this.allSkillBooks = [...this.normalSkillBooks, ...d_books_dly, ...d_books_ws, ...d_books_yx];

        for (let item of this.allSkillBooks) {
            this.allSkillBooksMap[item.id] = item;
            this.allSkillIds.push(item.id);
        }
    }
    getSkillBookById(id: string) {
        return this.allSkillBooksMap[id];
    }
    getSkillIdByBookId(id: string) {
        return this.allSkillBooksMap[id]?.ClassAbilityId;
    }
}
